package com.huangdemo.dao.first;

import com.huangdemo.model.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface StudentMapper {
	@Select("SELECT * FROM student")
	List<Student> queryStudents();

	@Update("<script>" +
			" update student set age=5 where id in " +
			" <foreach collection='list' item='id' index='index' open='('  separator=',' close=')' >" +
			" #{id}" +
			" </foreach>" +
			"</script>")
	void updateTest(List<Integer> list);

	@Update("<script>" +
			" <foreach collection='list' item='id' index='index' open='' close='' separator=';'  >" +
			" update student set age=#{index} where id = #{index}" +
			" </foreach>" +
			"</script>")
	void updateTest1(List<Integer> list);
}
